#include "MediaChannel.h"
//#include "ScenesManager.h"
#include "Util/logc.h"
#include "Util/logger.h"
namespace Media {
    CDeviceMediaChannel::CDeviceMediaChannel(int video, int audio) : MediaChannel(video, audio) {
        m_source_ptr = RealStreamSource::create(video, audio);
    }

    CDeviceMediaChannel::~CDeviceMediaChannel() {
        CDeviceMediaChannel::Stop();
    }


    bool CDeviceMediaChannel::Start(void *call_this, frame_callback_func callback) {
        return m_source_ptr->start(call_this, callback);
    }

    bool CDeviceMediaChannel::Stop() {
        return m_source_ptr->stop(m_call_this);
    }

    bool CDeviceMediaChannel::SetIFrame() {
        return m_source_ptr->setIFrame();
    }

    bool CDeviceMediaChannel::GetVideoFormat(VideoFormat &format) {
        VideoFormat uformat;
        bool ret = m_source_ptr->getVideoFormat(&uformat);
        if (ret) format = uformat;
        return ret;
    }


    bool CDeviceMediaChannelEx::Start(void *call_this, frame_callback_func callback) {
//        Scenes::Ptr scenes;
//        if(ScenesManager::Instance()->GetOneScenes(m_scenesId,scenes)){
//            scenes->SetFrameOutCb([call_this, callback](const FrameCommon::Frame::Ptr& frame){
//                callback(frame);
//            });
//            return true;
//        }
//        errorf("not found scenes %d", m_scenesId);
        return false;
    }

    CDeviceMediaChannelEx::CDeviceMediaChannelEx(int scenesId) : MediaChannel(0, 0) {
        tracef("CDeviceMediaChannelEx scenesId %d", scenesId);
        m_scenesId = scenesId;
    }

    bool CDeviceMediaChannelEx::Stop() {
        return true;
    }

    bool CDeviceMediaChannelEx::SetIFrame() {
        return true;
    }

    bool CDeviceMediaChannelEx::GetVideoFormat(VideoFormat &format) {
        return true;
    }

    CDeviceMediaChannelEx::~CDeviceMediaChannelEx() = default;
}